#!/bin/sh
# case.sh - Using the case selection structure

my_usage ()
{
    echo 'Press a, b, c, or q. Type "q" and press ENTER to exit'
}

clear
my_usage
read OPT

while [ true ]  # 类似于宏定义TRUE
do
    case $OPT in
        a)  echo 'You pressed "a"';;    # 和C语言中的break等价
        b)  echo 'You pressed "b"';;
        c)  echo 'You pressed "c"';;
        q)  exit 0;;
        ?)  clear && my_usage;;
    esac        # case段结束标志
    read OPT    # 准备读入字符(串)并赋值给OPT
done
